<%@page import="multiface.web.util.categories.AlberoCategorieRicambi"%>
<%@page import="multiface.web.util.categories.AlberoCategorieProdotti"%>
<%@page import="multiface.awwadco.jpa.Utente"%>
<%@page import="multiface.web.util.PagerList"%>
<%@page import="javax.persistence.Query"%>
<%@page import="java.util.LinkedList"%>
<%
    Utente ut = (Utente) session.getAttribute("admin");
    if (ut == null) {
        response.sendRedirect(multiface.web.util.ServletUtils.getBaseUrl(request) + "/admin/index.jsp?err=y");
    }
%>

<%@page import="java.util.Iterator"%>
<%@page import="multiface.awwadco.jpa.Categoria"%>
<%@page import="java.util.List"%>
<%@page import="javax.persistence.RollbackException"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="multiface.awwadco.jpa.PersistenceManager"%>

<script type="text/javascript">
    $(document).ready(function(){
        $("#formBox").validate();
    });
</script>

<div class="box">
    <form class="formBox" id="formBox" method="post" action="">
        <%
            EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
            EntityManager em = emf.createEntityManager();

            String cid = request.getParameter("cid");

            Categoria p = em.createNamedQuery("Categoria.findByIdcategoria", Categoria.class).setParameter("idcategoria", Integer.parseInt(cid)).getSingleResult();

            em.close();
            //emf.close();
%>
        <div class="title">Modify Category</div>
        <br>
        <div class="inputs">
            <label for="nome">Name of the Category</label>
            <input name="nome" id="nome" maxlength="255" class="required" type="text" value="<%=p.getNome()%>"/>
        </div>

        <input name="ordine" id="ordine" hidden="true" type="text" value="<%=p.getOrdine()%>"/>
        <input name="ricambio" id="ricambio" hidden="true" type="checkbox" value="0"/>
        <input name="sopracategoria" id="sopracategoria" type="hidden" value="<%=p.getSopracategoria()%>"/>
        <input id="idcategoria" type="hidden" value="<%=p.getIdcategoria()%>"/>
    </form>
</div>
